var _util = require('util/util.js');

var _account_servcie = {

    checkLogin : function(resolve, reject) {
        _util.request({
            url     : _util.getServerURL('accounts/get_login_account_info'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    login : function(account, resolve, reject) {
        _util.request({
            url     : _util.getServerURL('accounts/signon'),
            method  : 'POST',
            data    : account,
            success : resolve,
            error   : reject
        });
    },
       
    signOn : function (resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('accounts/signoff'),
            method: "POST",
            success: resolve,
            error: reject,
        });
    }, 

    myAccount : function (resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('accounts/myAccount'),
            success: resolve,
            error: reject,
        });
    }, 

    update: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('accounts/update'),
            data: account,
            method: "PUT",
            success: resolve,
            error: reject,
        })
    },

    signUp: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('accounts/signup'),
            data: account,
            method: "POST",
            success: resolve,
            error: reject,
        })
    },
    updatePassword: function (account, resolve, reject) {
        _util.request({
            url: _util.getServerURL('accounts/password'),
            data: account,
            method: "PUT",
            success: resolve,
            error: reject,
        })

    },
    isUsernameExist: function (username, resolve, reject) {
        _util.request({
            //后端的url
            url: _util.getServerURL('accounts/user_exist/') + username,
            method: "GET",
            success: resolve,
            error: reject,
        });
    },
}

module.exports = _account_servcie;